package jp.wug.samples.cart;

import com.google.inject.Inject;
import jp.wug.Renderer;

public class BuyPage {
    Models.Cart cart;

    @Inject
    public BuyPage(Models.Cart cart) {
        this.cart = cart;
    }

    public void renderCartItems(Renderer<String, Models.Product> renderer) {
        for (Models.CartItem item : cart.getItems()) {
            for (int i = 0; i < item.getCount(); i++) {
                Models.Product product = item.getProduct();
                renderer.render(product.getKey(), product);
            }
        }
    }

    public Models.Product getCartItem(String key) {
        return cart.getItem(key).getProduct();
    }
}
